import React, {Component} from 'react';
import { connect } from 'react-redux'

import { changeUiTitle } from '../../store/actions/ui'
import './cart.less'
import CartItem from './CartItem'

const mapState=state=>{
    return{
        cartList:state.cart.list
    }
}

@connect(mapState,{ changeUiTitle })
class Cart extends Component {
    componentDidMount() {
        this.props.changeUiTitle('购物车');
    }
    render() {
        return (
            <div>
               <ul className="pro-cart">
                   {
                       this.props.cartList.map(item=>{
                           return <CartItem  key={item.id} {...item}/>
                       })
                   }

               </ul>
            </div>
        );
    }
}

export default Cart;